using System;
using System.Collections.Generic;
using UnityEngine;

public class Database : MonoBehaviour
{
	[Serializable]
	public struct Data
	{
		public double cash;

		public int superCash;

		public int targetMine;

		public int dailyGifts;

		public int foreverBoost;

		public int idleCashBoost;

		public string lastGift;

		public List<Mine> mine;

		public SkillBuilder.Properties skill;

		public Collectible.Properties collectible;

		public void Initialize()
		{
			foreverBoost = 1;
			idleCashBoost = 1;
			collectible = default(Collectible.Properties);
			collectible.Initialize();
			Mine item = default(Mine);
			item.Initialize();
			mine = new List<Mine>();
			mine.Add(item);
		}
	}

	[Serializable]
	public struct Mine
	{
		public double idleCash;

		public string offline;

		public int fenceIndex;

		public int resetCount;

		public int adsBoostRemaining;

		public int elevatorRecruitment;

		public int warehouseRecruitment;

		public int mineShaftRecruitment;

		public List<Profile> profile;

		public Fence.Properties fence;

		public List<Item> itemList;

		public List<ItemBoost> itemBoost;

		public Elevator.Properties elevator;

		public Warehouse.Properties warehouse;

		public List<MineShaft.Properties> mineShaft;

		public void Initialize()
		{
			idleCash = 0.0;
			fenceIndex = 0;
			adsBoostRemaining = 0;
			offline = string.Empty;
			elevatorRecruitment = 0;
			warehouseRecruitment = 0;
			mineShaftRecruitment = 0;
			itemList = new List<Item>();
			profile = new List<Profile>();
			fence = default(Fence.Properties);
			itemBoost = new List<ItemBoost>();
			elevator = default(Elevator.Properties);
			warehouse = default(Warehouse.Properties);
			mineShaft = new List<MineShaft.Properties>();
		}
	}

	private Data data;

	[SerializeField]
	private Setting setting;

	public Data GetData => data;

	public void SetData(Data data)
	{
		this.data = data;
		PlayerPrefs.SetString(setting.configuration.dataName, JsonUtility.ToJson(data));
	}

	private void Awake()
	{
		data = JsonUtility.FromJson<Data>(PlayerPrefs.GetString(setting.configuration.dataName, JsonUtility.ToJson(data)));
	}
}
